//
//  UITestViewController.m
//  UITest
//

#import "UITestViewController.h"
#import "roundedCornerView.h"

@implementation UITestViewController

CGFloat radiansForDegrees(CGFloat degrees)
{
	return (M_PI * degrees / 180.0);
}

- (void)viewDidLoad {

    [super viewDidLoad];

	CGPoint frameCenter = self.view.center;
	float width = 50.0;
	float height = 50.0;
	
	CGRect viewFrame = CGRectMake(frameCenter.x-width,
								  frameCenter.y-height,
								  width*2, height*2);
	
	roundedCornerView *myView = [[roundedCornerView alloc]
								 initWithFrame:viewFrame];

	myView.backgroundColor = [UIColor blueColor];
	[[self view] addSubview:myView];

	CGRect subViewFrame = CGRectInset(myView.bounds,
									  width/2.0, height/2.0);
	roundedCornerView *mySubview = [[roundedCornerView alloc]
									initWithFrame:subViewFrame];
	mySubview.backgroundColor = [UIColor yellowColor];
	[myView addSubview:mySubview];
	
	[UIView beginAnimations:nil context:NULL];
	
	[UIView setAnimationDuration:1.0];
	
	CGAffineTransform scale = CGAffineTransformMakeScale(2.0, 2.0);
	CGAffineTransform rotate = CGAffineTransformMakeRotation(radiansForDegrees(180));
	CGAffineTransform myTransform = CGAffineTransformConcat(scale, rotate);
	myView.transform = myTransform;
	
	[UIView commitAnimations];
	
	[mySubview release];
	[myView release];
}

- (void)dealloc {
    [super dealloc];
}

@end
